Skip to content

feat: add env to disable debug log - #1222

Closed
vinnymac wants to merge 1 commit into
openai:masterfrom
vinnymac:vt/disable-debug
Closed

vinnymac wants to merge 1 commit into
openai:masterfrom
vinnymac:vt/disable-debug

Conversation

@vinnymac

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Adds the ability to completely disable debug logging.

This is a stopgap, if I was requesting an actual fix it would be to implement an inversion of control, and enable the user of this sdk to specify the logger, that way this flag becomes unnecessary. This simple workaround is more than enough for my needs.

Additional context & links

#302

@vinnymac
vinnymac requested a review from a team as a code owner December 11, 2024 01:52
Comment thread src/core.ts
typeof process !== 'undefined' &&
typeof process?.env?.['OPENAI_DISABLE_DEBUG'] !== 'string' &&
process?.env?.['DEBUG'] === 'true'
) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify the condition by avoiding redundant optional chaining (?.) on process.env.

if (
  typeof process !== 'undefined' &&
  process?.env && 
  typeof process.env['OPENAI_DISABLE_DEBUG'] !== 'string' &&
  process.env['DEBUG'] === 'true'
) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could!

However, I won't be making any more changes until I hear from a collaborator on whether or not this PR or a change like it would be merged.

Thanks

@JackNeto

Copy link
Copy Markdown

Can this be merged please? The solution has already been presented months ago.

@RobertCraigie

Copy link
Copy Markdown
Contributor

Hey thanks for the PR and very sorry for the delayed response here. We've added full logging support in v5 with an environment variable to disable it https://github.com/openai/openai-node?tab=readme-ov-file#logging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants